cssimage: Warn if gradients only have 1 color stop
authorBenjamin Otte <otte@redhat.com>
Mon, 18 Apr 2016 18:25:11 +0000 (20:25 +0200)
committerBenjamin Otte <otte@redhat.com>
Mon, 18 Apr 2016 18:52:35 +0000 (20:52 +0200)
GTK <= 3.20 allowed that but the CSS spec and borwsers do not.
We might want to just remove that feature, but for now, we just warn.

gtk/gtkcssimagelinear.c
gtk/gtkcssimageradial.c

index b4a53f563362578176b92045a9f25a108294fe6a..07ab3eacf594d6cd6a32437fa1cab1ab798d504e 100644 (file)
@@ -352,6 +352,14 @@ gtk_css_image_linear_parse (GtkCssImage  *image,
 
   } while (_gtk_css_parser_try (parser, ",", TRUE));
 
+  if (linear->stops->len < 2)
+    {
+      _gtk_css_parser_error_full (parser,
+                                  GTK_CSS_PROVIDER_ERROR_DEPRECATED,
+                                  "Using one color stop with %s() is deprecated.",
+                                  linear->repeating ? "repeating-linear-gradient" : "linear-gradient");
+    }
+
   if (!_gtk_css_parser_try (parser, ")", TRUE))
     {
       _gtk_css_parser_error (parser, "Missing closing bracket at end of linear gradient");
index bc137db7da226c9e278de0a31d7329df9875a042..81967c9a80c26f18beecabe72bb81987180dfbd3 100644 (file)
@@ -377,6 +377,14 @@ gtk_css_image_radial_parse (GtkCssImage  *image,
 
   } while (_gtk_css_parser_try (parser, ",", TRUE));
 
+  if (radial->stops->len < 2)
+    {
+      _gtk_css_parser_error_full (parser,
+                                  GTK_CSS_PROVIDER_ERROR_DEPRECATED,
+                                  "Using one color stop with %s() is deprecated.",
+                                  radial->repeating ? "repeating-radial-gradient" : "radial-gradient");
+    }
+
   if (!_gtk_css_parser_try (parser, ")", TRUE))
     {
       _gtk_css_parser_error (parser, "Missing closing bracket at end of radial gradient");